import 'package:flutter/material.dart';

// https://pub.dev/packages/scrollable_positioned_list
// 实在不行滑动到index用这个
class VerticalPageView extends StatefulWidget {
  const VerticalPageView({Key key}) : super(key: key);

  @override
  _VerticalPageViewState createState() => _VerticalPageViewState();
}

class _VerticalPageViewState extends State<VerticalPageView> {
  PageController _pageController = PageController(viewportFraction: 1);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("vertical page view"),
      ),
      body: Container(
        alignment: Alignment.topCenter,
        child: PageView.builder(
          controller: _pageController,
          itemBuilder: (context, index) {
            return Container(
              height: 50,
              width: 50,
              margin: EdgeInsets.all(10),
              color: Colors.red,
            );
          },
          scrollDirection: Axis.vertical,
          itemCount: 3,
          // 不整块滑动
          pageSnapping: false,
        ),
      ),
    );
  }
}
